package com.shop.commom.utils;

import lombok.Data;
import org.springframework.http.HttpStatus;

@Data
public class JSONResult<T> {

    private Integer status;

    private String msg;

    private T data;


    public static JSONResult OK(Object objects){
        JSONResult result = new JSONResult();
        result.setStatus(HttpStatus.OK.value());
        result.setData(objects);
        return result;
    }

    public static JSONResult OK(){
        JSONResult result = new JSONResult();
        result.setStatus(HttpStatus.OK.value());
        return result;
    }

    public static JSONResult error(String msg){
        JSONResult result = new JSONResult();
        result.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
        result.setMsg(msg);
        return result;
    }

}
